/*
 * Camera.h
 *
 *  Created on: May 13, 2012
 *      Author: mklingen
 */

#ifndef CAMERA_H
#define CAMERA_H
#include <SFML/Graphics.hpp>
#include <Eigen/Core>
#include <QKeyEvent>
#include <QMouseEvent>

namespace kling
{

    class Camera
    {
        public:
            Camera(double width, double height);
            virtual ~Camera();

            void Update(double dt);

            inline Eigen::Vector2d GetVelocity() { return m_velocity; }
            inline void Accelerate(Eigen::Vector2d accel) { m_velocity += accel; }
            inline void Move(Eigen::Vector2d motion) { SetPosition(m_position + motion); }
            inline void SetPosition(Eigen::Vector2d position) { m_position = position; m_view->SetCenter(position.x(), -position.y()); }
            inline double SetZoom(double zoom) { m_view->Zoom(zoom); }


            inline sf::View* GetView() { return m_view; }
            inline bool IsKeyPressed(int key){ if(m_isKeyPressed.find(key) == m_isKeyPressed.end()) { return false; } else return m_isKeyPressed[key]; }

            virtual void HandleKeyEvent(QKeyEvent* keyEvent);
            virtual void HandleMouseEvent(QMouseEvent* mouseEvent);

        private:
            Eigen::Vector2d m_position;
            Eigen::Vector2d m_velocity;
            sf::View* m_view;
            std::map<int, bool> m_isKeyPressed;
    };

} /* namespace kling */
#endif /* CAMERA_H_ */
